<?php

namespace app\http\middleware;

use think\facade\Config;
use app\common\logic\Base;
use app\common\tools\ReturnCode;


class AdminResponse extends Base
{
    public function handle($request, \Closure $next) {

        $header = Config::get('apiadmin.CROSS_DOMAIN');
        //header($header);

        if ($request->isOptions()) {
            return $this->buildSuccess([],ReturnCode::SUCCESS[0], ReturnCode::SUCCESS[1])->header($header);//return $this->buildSuccess([]);
        }
        return $next($request)->header(Config::get('apiadmin.CROSS_DOMAIN'));
        return $next($request);



        $header = Config::get('apiadmin.CROSS_DOMAIN');

        //$aa = $request->isOptions();
        //return $this->buildSuccess($aa, ReturnCode::SUCCESS[1])->header($header);

        if ($request->isOptions()) {
            return $this->buildSuccess(ReturnCode::SUCCESS[0], ReturnCode::SUCCESS[1])->header($header);//return $this->buildSuccess([]);
        } /*else {
            return $this->buildFailed(ReturnCode::INVALID, '接口地址异常', []);
        }*/
        //return $this->buildSuccess(ReturnCode::SUCCESS[0], ReturnCode::SUCCESS[1])->header($header);
        return $next($request)->header($header);
        //return $next($request)->header($header);
        //return $next($request)->header(Config::get('apiadmin.CROSS_DOMAIN'));
    }
}
